package leetcode;

/**
 * Created with IntelliJ IDEA.
 * User: Ghost
 * Date: 14-6-10
 * Time: 下午7:36
 * To change this template use File | Settings | File Templates.
 */
public class Remove_Duplicates_from_Sorted_List {
    public static ListNode deleteDuplicates(ListNode head) {
        ListNode current = head;
        while(current!=null){
            int num = current.val;
            ListNode Next = current.next;
            while(Next!=null && Next.val==num)
                Next = Next.next;
            current.next = Next;
            current = current.next;
        }
        return head;
    }
    public static void main(String[] args){
        ListNode head = new ListNode(1);
        head.next = new ListNode(2);
        head.next.next = new ListNode(3);
        ListNode hh = deleteDuplicates(head);
        System.out.println(hh.val);
        System.out.println(hh.next.val);
        System.out.println(hh.next.next.val);
    }
}
